using BuildingBlocks.Presentation.Endpoints;
using BuildingBlocks.Presentation.Results;
using Mediator;

namespace Basket.Api.Features.Baskets.Delete;

internal sealed class DeleteBasketEndpoint : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        app.MapDelete(
                $"{BasketRoutes.Base}",
                async (IMediator mediator, CancellationToken cancellationToken) =>
                {
                    var result = await mediator.Send(new DeleteBasketCommand(), cancellationToken);
                    return result.Match(Results.NoContent, ApiResponse.Problem);
                })
            .WithName("DeleteBasket")
            .WithTags("Basket");
    }
}
